<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Indexs extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('warehouse_storage')
             ->addIndex('warehouse_id', ['name' => 'warehouse_storage_warehouse_id'])
             ->addIndex('warehouse_area_id', ['name' => 'warehouse_storage_warehouse_area_id'])
             ->addIndex('name', ['name' => 'warehouse_storage_name'])
             ->update();

        $this->table('warehouse_area')
             ->addIndex('warehouse_id', ['name' => 'warehouse_area_warehouse_id'])
             ->addIndex('name', ['name' => 'warehouse_area_name'])
             ->update();

        $this->table('warehouse')
             ->addIndex('company_id', ['name' => 'warehouse_company_id'])
             ->addIndex('name', ['name' => 'warehouse_name'])
             ->addIndex('mobile', ['name' => 'warehouse_mobile'])
             ->addIndex('real_name', ['name' => 'warehouse_real_name'])
             ->update();


        $this->table('supplier_user')
             ->addIndex('company_id', ['name' => 'supplier_user_company_id'])
             ->addIndex('user_name', ['name' => 'supplier_user_user_name'])
             ->addIndex('mobile', ['name' => 'supplier_user_mobile'])
             ->addIndex('real_name', ['name' => 'supplier_user_real_name'])
             ->addIndex(['supplier_id', 'is_super', 'id_number'], ['name' => 'supplier_user_supplier'])
             ->update();


        $this->table('supplier')
             ->addIndex('company_id', ['name' => 'supplier_company_id'])
             ->addIndex('name', ['name' => 'supplier_name'])
             ->addIndex('abbreviation', ['name' => 'supplier_abbreviation'])
             ->update();


        $this->table('store_user_oauth')
             ->addIndex('company_id', ['name' => 'store_user_oauth_company_id'])
             ->addIndex('store_user_id', ['name' => 'store_user_oauth_store_user_id'])
             ->addIndex('union_id', ['name' => 'store_user_oauth_union_id'])
             ->addIndex('oauth_type', ['name' => 'store_user_oauth_oauth_type'])
             ->update();

        $this->table('store_user_credit')
             ->addIndex('store_user_id', ['name' => 'store_user_credit_store_user_id'])
             ->addIndex('store_order_id', ['name' => 'store_user_credit_store_order_id'])
             ->addIndex('type', ['name' => 'store_user_credit_type'])
             ->update();


        $this->table('store_user_bank')
             ->addIndex('store_user_id', ['name' => 'store_user_bank_store_user_id'])
             ->addIndex('store_id', ['name' => 'store_user_bank_store_id'])
             ->addIndex('user_name', ['name' => 'store_user_bank_user_name'])
             ->addIndex('bank_type', ['name' => 'store_user_bank_type'])
             ->addIndex('bank_no', ['name' => 'store_user_bank_bank_no'])
             ->update();


        $this->table('store_user_account_detail')
             ->addIndex('company_user_id', ['name' => 'store_user_account_detail_company_user_id'])
             ->addIndex('store_user_id', ['name' => 'store_user_account_detail_store_user_id'])
             ->addIndex('store_user_account_id', ['name' => 'store_user_account_detail_store_user_account_id'])
             ->update();


        $this->table('store_user_account')
             ->addIndex('store_user_id', ['name' => 'store_user_account_store_user_id'])
             ->update();


        $this->table('store_user')
             ->addIndex('company_id', ['name' => 'store_user_company_id'])
             ->addIndex('store_id', ['name' => 'store_user_store_id'])
             ->addIndex('mobile', ['name' => 'store_user_mobile'])
             ->addIndex('real_name', ['name' => 'store_user_real_name'])
             ->update();


        $this->table('store_order_storage')
             ->addIndex('store_order_id', ['name' => 'store_order_storage_store_order_id'])
             ->addIndex('store_order_detail_id', ['name' => 'store_order_storage_store_order_detail_id'])
             ->addIndex('company_order_storage_id', ['name' => 'store_order_storage_company_order_storage_id'])
             ->addIndex('warehouse_storage_id', ['name' => 'store_order_storage_warehouse_storage_id'])
             ->addIndex('goods_id', ['name' => 'store_order_storage_goods_id'])
             ->addIndex('goods_rule_id', ['name' => 'store_order_storage_goods_rule_id'])
             ->update();


        $this->table('store_order_profit')
             ->addIndex('store_order_id', ['name' => 'store_order_profit_store_order_id'])
             ->addIndex('store_order_detail_id', ['name' => 'store_order_profit_store_order_detail_id'])
             ->addIndex('goods_id', ['name' => 'store_order_profit_goods_id'])
             ->update();


        $this->table('store_order_log')
             ->addIndex('store_order_id', ['name' => 'store_order_log_store_order_id'])
             ->update();


        $this->table('store_order_detail')
             ->addIndex('store_user_id', ['name' => 'store_order_detail_store_user_id'])
             ->addIndex('store_order_id', ['name' => 'store_order_detail_store_order_id'])
             ->addIndex('goods_id', ['name' => 'store_order_detail_goods_id'])
             ->addIndex('goods_rule_id', ['name' => 'store_order_detail_goods_rule_id'])
             ->update();

        $this->table('store_order')
             ->addIndex('company_id', ['name' => 'store_order_company_id'])
             ->addIndex('store_id', ['name' => 'store_order_store_id'])
             ->addIndex('store_user_id', ['name' => 'store_order_store_user_id'])
             ->addIndex(['company_id', 'store_id', 'store_user_id', 'no'], ['name' => 'store_order_company'])
             ->addIndex('no', ['name' => 'store_order_no'])
             ->addIndex('pay_type', ['name' => 'store_order_pay_type'])
             ->update();


        $this->table('store_cart')
             ->addIndex('store_user_id', ['name' => 'store_cart_store_user_id'])
             ->addIndex('goods_id', ['name' => 'store_cart_goods_id'])
             ->addIndex('goods_rule_id', ['name' => 'store_cart_goods_rule_id'])
             ->update();


        $this->table('store')
             ->addIndex('company_id', ['name' => 'store_company_id'])
             ->addIndex('supplier_id', ['name' => 'store_supplier_id'])
             ->addIndex('name', ['name' => 'store_name'])
             ->update();


        $this->table('picking_store')
             ->addIndex('company_id', ['name' => 'picking_store_company_id'])
             ->addIndex('store_id', ['name' => 'picking_store_store_id'])
             ->addIndex('name', ['name' => 'picking_store_name'])
             ->update();


        $this->table('picking_line')
             ->addIndex('company_id', ['name' => 'picking_line_company_id'])
             ->addIndex('deliver_line_id', ['name' => 'picking_line_deliver_line_id'])
             ->addIndex('name', ['name' => 'picking_line_name'])
             ->update();


        $this->table('goods_spec')
             ->addIndex('goods_id', ['name' => 'goods_spec_goods_id'])
             ->addIndex('name', ['name' => 'goods_spec_name'])
             ->update();

        $this->table('goods_rule')
             ->addIndex('goods_id', ['name' => 'goods_rule_goods_id'])
             ->update();


        $this->table('goods_cate')
             ->addIndex('name', ['name' => 'goods_cate_name'])
             ->update();


        $this->table('goods')
             ->addIndex('name', ['name' => 'goods_name'])
             ->addIndex('no', ['name' => 'goods_no'])
             ->addIndex('goods_cate_id_one', ['name' => 'goods_goods_cate_id_one'])
             ->addIndex('goods_cate_id_two', ['name' => 'goods_goods_cate_id_two'])
             ->update();


        $this->table('deliver_task')
             ->addIndex('company_id', ['name' => 'deliver_task_company_id'])
             ->addIndex('no', ['name' => 'deliver_task_no'])
             ->addIndex('deliver_line_id', ['name' => 'deliver_task_deliver_line_id'])
             ->addIndex('deliver_line_no', ['name' => 'deliver_task_deliver_line_no'])
             ->addIndex('deliver_driver_id', ['name' => 'deliver_task_deliver_driver_id'])
             ->update();


        $this->table('deliver_line')
             ->addIndex('company_id', ['name' => 'deliver_line_company_id'])
             ->addIndex('no', ['name' => 'deliver_line_no'])
             ->addIndex('name', ['name' => 'deliver_line_name'])
             ->addIndex('warehouse_id', ['name' => 'deliver_line_warehouse_id'])
             ->addIndex('deliver_driver_id', ['name' => 'deliver_line_deliver_driver_id'])
             ->update();

        $this->table('deliver_driver_withdraw')
             ->addIndex('company_id', ['name' => 'deliver_driver_withdraw_company_id'])
             ->addIndex('no', ['name' => 'deliver_driver_withdraw_no'])
             ->addIndex('deliver_driver_id', ['name' => 'deliver_driver_withdraw_deliver_driver_id'])
             ->update();

        $this->table('deliver_driver_account_log')
             ->addIndex('company_id', ['name' => 'deliver_driver_account_log_company_id'])
             ->addIndex('withdraw_no', ['name' => 'deliver_driver_account_log_withdraw_no'])
             ->addIndex('deliver_driver_id', ['name' => 'deliver_driver_account_log_deliver_driver_id'])
             ->update();


        $this->table('deliver_driver')
             ->addIndex('company_id', ['name' => 'deliver_driver_company_id'])
             ->addIndex('name', ['name' => 'deliver_driver_name'])
             ->addIndex('mobile', ['name' => 'deliver_driver_mobile'])
             ->addIndex('no', ['name' => 'deliver_driver_no'])
             ->addIndex('user_name', ['name' => 'deliver_driver_user_name'])
             ->update();


        $this->table('deliver_car')
             ->addIndex('company_id', ['name' => 'deliver_car_company_id'])
             ->addIndex('no', ['name' => 'deliver_car_no'])
             ->update();


        $this->table('config_mini')
             ->addIndex('company_id', ['name' => 'config_mini_company_id'])
             ->addIndex('appid', ['name' => 'config_mini_appid'])
             ->addIndex('name', ['name' => 'config_mini_name'])
             ->update();

        $this->table('company_user_role')
             ->addIndex('company_user_id', ['name' => 'company_user_role_company_user_id'])
             ->addIndex('company_role_id', ['name' => 'company_user_role_company_role_id'])
             ->update();


        $this->table('company_user_log')
             ->addIndex('company_user_id', ['name' => 'company_user_log_company_user_id'])
             ->update();


        $this->table('company_user')
             ->addIndex('user_name', ['name' => 'company_user_user_name'])
             ->addIndex('real_name', ['name' => 'company_user_real_name'])
             ->addIndex('company_id', ['name' => 'company_user_company_id'])
             ->update();

        $this->table('company_role_menu')
             ->addIndex('company_role_id', ['name' => 'company_role_menu_company_role_id'])
             ->addIndex('company_menu_id', ['name' => 'company_role_menu_company_menu_id'])
             ->update();

        $this->table('company_role')
             ->addIndex('company_id', ['name' => 'company_role_company_id'])
             ->addIndex('name', ['name' => 'company_role_name'])
             ->update();

        $this->table('company_order_storage')
             ->addIndex(['company_id', 'company_order_detail_id', 'warehouse_id', 'warehouse_area_id', 'warehouse_storage_id', 'goods_id', 'goods_rule_id', 'company_order_id'], ['name' => 'company_order_storage_company_id'])
             ->addIndex('company_order_detail_id', ['name' => 'company_order_storage_company_order_detail_id'])
             ->addIndex('warehouse_id', ['name' => 'company_order_storage_warehouse_id'])
             ->addIndex('warehouse_area_id', ['name' => 'company_order_storage_warehouse_area_id'])
             ->addIndex('warehouse_storage_id', ['name' => 'company_order_storage_warehouse_storage_id'])
             ->addIndex('goods_id', ['name' => 'company_order_storage_goods_id'])
             ->addIndex('goods_rule_id', ['name' => 'company_order_storage_goods_rule_id'])
             ->addIndex('company_order_id', ['name' => 'company_order_storage_company_order_id'])
             ->update();

        $this->table('company_order_log')
             ->addIndex('company_order_id', ['name' => 'company_order_log_company_order_id'])
             ->update();


        $this->table('company_order_detail')
             ->addIndex('company_order_id', ['name' => 'company_order_detail_company_order_id'])
             ->addIndex('company_id', ['name' => 'company_order_detail_company_id'])
             ->addIndex('goods_id', ['name' => 'company_order_detail_goods_id'])
             ->addIndex('goods_rule_id', ['name' => 'company_order_detail_goods_rule_id'])
             ->update();


        $this->table('company_order')
             ->addIndex('no', ['name' => 'company_order_detail_no'])
             ->addIndex('company_id', ['name' => 'company_order_detail_company_id'])
             ->addIndex('company_user_id', ['name' => 'company_order_detail_company_user_id'])
             ->addIndex('order_status', ['name' => 'company_order_detail_order_status'])
             ->update();


        $this->table('company_order')
             ->addIndex('no', ['name' => 'company_order_no'])
             ->addIndex('company_id', ['name' => 'company_order_company_id'])
             ->addIndex('company_user_id', ['name' => 'company_order_company_user_id'])
             ->addIndex('order_status', ['name' => 'company_order_order_status'])
             ->update();



        $this->table('company_goods_store')
             ->addIndex('store_id', ['name' => 'company_goods_store_store_id'])
             ->addIndex('goods_id', ['name' => 'company_goods_store_goods_id'])
             ->addIndex('company_goods_id', ['name' => 'company_goods_store_company_goods_id'])
             ->addIndex('company_id', ['name' => 'company_goods_store_company_id'])
             ->update();

        $this->table('company_menu')
             ->addIndex('name', ['name' => 'company_menu_name'])
             ->update();

        $this->table('company_goods_rule')
             ->addIndex('goods_id', ['name' => 'company_goods_rule_goods_id'])
             ->addIndex('company_id', ['name' => 'company_goods_rule_company_id'])
            ->addIndex('goods_rule_id', ['name' => 'company_goods_rule_goods_rule_id'])
             ->update();


        $this->table('company_goods')
             ->addIndex('goods_id', ['name' => 'company_goods_goods_id'])
             ->addIndex('company_id', ['name' => 'company_goods_company_id'])
             ->addIndex('goods_cate_id_one', ['name' => 'company_goods_goods_cate_id_one'])
             ->addIndex('goods_cate_id_two', ['name' => 'company_goods_goods_cate_id_two'])
             ->update();

        $this->table('company_goods_rate')
             ->addIndex('goods_id', ['name' => 'company_goods_rate_goods_id'])
             ->addIndex('company_id', ['name' => 'company_goods_rate_company_id'])
             ->update();


        $this->table('company')
             ->addIndex('name', ['name' => 'company_name'])
             ->addIndex('abbreviation', ['name' => 'company_abbreviation'])
             ->update();


    }
}
